<?php
namespace User\Model;
use Think\Model;

class EventUserModel extends Model
{
	protected $tableName = "event_user";
	protected $_validate = array(
		array( "id", "require", "没有查到相关活动信息", self::MUST_VALIDATE, '', self::MODEL_BOTH ),//上传者ID;在新增字段的时候进行验证
		array( "username", "require", "用户名不能为空", self::MUST_VALIDATE, "", self::MODEL_BOTH ),
		
	
	);


	public function login( $username, $password, $openid='')
	{
        $user = $this->where(array('username'=>$username, 'password'=>$password))->find();
        
        if( $user != null)
        {
            //登录成功
            session('event_user', $user);

            //update openid
            $this->where(array('id'=>$user['id']))->setField('openid', $openid);
            //return
            return true;
        }
        else
        {
            //登录失败
            return false;
        }

	}
}
?>